package pt.inescid.components.policyengine.heimdall.pap.base;

import java.util.Vector;

public class SubPolicyDefinition extends SimpleDefinition {

	private DomainDefinition domain;
	private float minimumNodeQuorum = (float) 0;
	private PolicyDefinition policy;
	
	public SubPolicyDefinition(int type, String valueType,
			RuleDefinition previousLevel, 
			String domain, String value,
			ModelDefinition currentModelDef) {
		super(type, valueType, previousLevel, value);
		this.domain = currentModelDef.getDomain(domain);
		this.policy = currentModelDef.getPolicy(value);
	}

//  ----------------------------------------------------------
//  ------------------------   toString   ------------------------
//  ----------------------------------------------------------
	public String toString() {
		String result = "";
		
		result += (domain == null ? "" : domain+ ".") + value;
		
		return (result);
	}

//  ----------------------------------------------------------
//  ------------------------   getFunction   ------------------------
//  ----------------------------------------------------------
	public String getFunction() {
		String result = "";
		
//		if (domain == null) {
//			result += 
//"		DomainInstance " + getTemporaryVar() + "A = \n" +
//"				DomainInstance.getLocalDomain();\n";	
//		}
//		else {
//			result += 
//"		DomainInstance " + getTemporaryVar() + "A = \n" +
//"				currentModel.getDomain(\"" + domain + "\");\n";				
//		}
//		
//		result +=
//"		boolean " + getTemporaryVar() + " = PolicyPIP.getEvaluationresult += (domain == null ? "" : domain + ".") + value + "()";
//		
		return (result);
	}

//  ----------------------------------------------------------
//  ------------------------   getParameters   ------------------------
//  ----------------------------------------------------------
	public Vector getParameters() {
		Vector allParameters = new Vector();
		return (allParameters);
	} // getParameters


	//  ----------------------------------------------------------
//  ------------------------   isPolicyComposition   ------------------------
//  ----------------------------------------------------------
	public boolean isPolicyComposition() {
		return (true);
	}


	public DomainDefinition getDomain() {
		return domain;
	}

	public float getMinimumNodeQuorum() {
		return minimumNodeQuorum;
	}

	public void setDomain(DomainDefinition domain) {
		this.domain = domain;
	}

	public void setMinimumNodeQuorum(float minimumNodeQuorum) {
		this.minimumNodeQuorum = minimumNodeQuorum;
	}

	public PolicyDefinition getPolicy() {
		return policy;
	}

	public void setPolicy(PolicyDefinition policy) {
		this.policy = policy;
	}


}; // SubPolicyExpression
